export default {
    namespaced: true,
    state: () => ({
        token: '',
		userId:'',
        userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}')
    }),
    mutations: {
        updateUserInfo(state, userInfo) {
            state.userinfo = userInfo;
        },
        updateToken(state, token) {
            state.token = token;
        },
        saveUserInfoToStorage(state) {
            uni.setStorageSync('userinfo', JSON.stringify(state.userinfo));
        },
		
		updateUserId(state, userId) {
		    state.userId = userId;
		},
    },
    actions: {
        updateUserInfoAndSave({ commit }, userInfo) {
            commit('updateUserInfo', userInfo);
            commit('saveUserInfoToStorage');
        }
    },
    getters: {}
}